<!-- 分类选择
    应用于：
        发布供求
   -->
<template>
<div>
    <!-- <el-cascader :options="productTypeListVal" v-model="value" @change="change" transfer :placeholder="placeholder" clearable filterable></el-cascader> -->
    <!-- <el-select v-model="value" :placeholder="placeholder" transfer clearable filterable @change="change">
        <el-option :key="item.id" :label="item.name" :value="item.id" v-for="(item) in listCategory">
        </el-option>
    </el-select> -->
    <el-select v-model="value" :placeholder="placeholder" transfer clearable filterable @change="change">
        <el-option-group v-for="group in listCategory" :key="group.label" :label="group.label">
            <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
        </el-option-group>
    </el-select>
</div>
</template>

<script>
export default {
    props: {
        placeholder: {
            type: String,
            default: 'Please choose'
        },
        val:{
            type:String,
        }
    },
    computed: {
        listCategory() {
            return this.$store.state.listCategory
        }
    },
    data() {
        return {
            value: '',
        }
    },
    mounted() {
        if(this.val){
            this.value=this.val
        }
    },
    methods: {
        change(value) {
            this.$emit('change', value)
        },
    }
}
</script>

<style lang="scss" scoped>
.el-select {
    width: 100%;
    :deep(&-group){
        padding-left: 1em;
        padding-right: 1em;
        box-sizing: border-box;
    }
}
</style>
